package com.heima.wemedia.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDTO;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {
    @Autowired
    WmMaterialService wmMaterialService;
    @PostMapping("upload_picture")
    public ResponseResult upload_picture(@RequestBody MultipartFile multipartFile){
        return wmMaterialService.upload_pictuies(multipartFile);
    }
    @PostMapping("list")
    public ResponseResult list(@RequestBody WmMaterialDTO wmMaterialDTO){
        return wmMaterialService.materialList(wmMaterialDTO);
    }
    @GetMapping("del_picture/{id}")
    public ResponseResult del_picture(@PathVariable Integer id){
        return wmMaterialService.del_picture(id);
    }
    @GetMapping("collect/{id}")
    public ResponseResult collect_picture(@PathVariable Integer id){
        return wmMaterialService.collect_picture(id,(short)1);
    }

    @GetMapping("cancel_collect/{id}")
    public ResponseResult cancel_collect_picture(@PathVariable Integer id){
        return wmMaterialService.collect_picture(id,(short)0);
    }




}
